@layout("/common/_curd/_container.html"){

<script type="text/javascript">
    var ctx = "${basePath}";
    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";

    $(function () {
        initGrid();
        initMenuBtn("btns", "${code}");
    });

    function initGrid() {
        var grid_url = ctx + "/${code}/countryList";
        var _colnames = ["",
            "名称",
            "贫困户",
            "贫困人口",
            "贫困村",
            "2016摘帽村",
            "2017摘帽村",
            "2018摘帽村",
            "2019摘帽村",
            "2016脱贫人数",
            "2017脱贫人数",
            "2018脱贫人数",
            "2019脱贫人数"];
        var _colmodel = [{name: "id", index: "id", hidden: true, width: 100},
            {name: "name", index: "name", width: 100},
            {name: "family", index: "family", width: 100},
            {name: "family_mans", index: "family_mans", width: 100},
            {name: "cuns", index: "cuns", width: 100},
            {name: "zmc_2016", index: "zmc_2016", width: 100},
            {name: "zmc_2017", index: "zmc_2017", width: 100},
            {name: "zmc_2018", index: "zmc_2018", width: 100},
            {name: "zmc_2019", index: "zmc_2019", width: 100},
            {name: "out_poor_2016", index: "out_poor_2016", width: 100},
            {name: "out_poor_2017", index: "out_poor_2017", width: 100},
            {name: "out_poor_2018", index: "out_poor_2018", width: 100},
            {name: "out_poor_2019", index: "out_poor_2019", width: 100}];

        jQuery(grid_selector).jqGrid({
            url: grid_url,
            shrinkToFit: true,
            colNames: _colnames,
            colModel: _colmodel,
            jsonReader: {id: "id"},
            pager: pager_selector,
            postData: {sort: "id", order: "asc"}
        });
    }
</script>


<!-- 配置 grid -->
<div class="row">
    <div class="col-xs-12 tb-grid">
        <!-- 配置 查询 -->
        @ var _col=[
        @ {name:"名称", index:"name", type:"text"}
        @];
        @ include("/common/_function/_search.html",{"col":_col}){}
        <!-- 按钮 -->
        <!--<div class="welljq well-sm" id="btns"></div>-->
        <div class="welljq well-sm" id="btns2">
            <button class="btn btn-xs btn-success " onclick="addCountry()" id="place_add_country">&nbsp;
                <li class=" fa fa-floppy-o bigger-120"></li>
                &nbsp;新增&nbsp;</button>
            &nbsp;
            <button class="btn btn-xs btn-warning " onclick="editCountry()" id="place_edit_country">&nbsp;
                <li class=" fa fa-pencil  bigger-120"></li>
                &nbsp;修改&nbsp;</button>
            &nbsp;
            <button class="btn btn-xs btn-danger " id="place_remove">&nbsp;
                <li class=" fa fa-times  bigger-120"></li>
                &nbsp;删除&nbsp;</button>
            &nbsp;
            <button class="btn btn-xs btn-primary " onclick="updateData()">&nbsp;
                <li class=" fa fa-times  bigger-120"></li>
                &nbsp;数据更新&nbsp;</button>
            &nbsp;
        </div>
        <!-- grid -->
        <table id="grid-table"></table>
        <!-- 分页-->
        <div id="grid-pager"></div>
    </div>
</div>

<!-- 引入所需的js -->
@include("/common/_listscript.html"){}
<script>
    addCountry = function () {
        layer.open({
            type: 2,
            title:"新增贫困乡",
            area: ["800px", "600px"],
            fix: false, //不固定
            maxmin: true,
            content: "/place/addCountry"
        });
    }
    editCountry = function () {
        var ids = $("#grid-table").jqGrid('getGridParam', 'selarrrow');
        if(ids.length <1){
            layer.msg("请选择一项")
        }else if(ids.length > 1){
            layer.msg("只能选择一项")
        }else{
            layer.open({
                type: 2,
                title:"修改贫困乡",
                area: ["800px", "600px"],
                fix: false, //不固定
                maxmin: true,
                content: "/place/editCountry/"+ids
            });
        }

    }
    updateData = function () {
        var index = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        $.post("${basePath}/ganluo/updateData", {}, function (data) {
            if (data.code === 0) {
                $jqGrid.jqGrid("setGridParam", { postData: { sort : "id", order : "asc" }, page: 1 }).trigger("reloadGrid");
                layer.close(index)
            } else {
                layer_post(data);
            }
        }, "json");

    }

</script>
@}	